<?php
// +-----------------+--------------------------------+------+-----+---------+----------------+
// | Field           | Type                           | Null | Key | Default | Extra          |
// +-----------------+--------------------------------+------+-----+---------+----------------+
// | id              | int(11)                        | NO   | PRI | NULL    | auto_increment |
// | name            | varchar(60)                    | NO   |     |         |                |
// | password        | varchar(64)                    | NO   |     |         |                |
// | nickname        | varchar(50)                    | YES  |     |         |                |
// | email           | varchar(100)                   | YES  |     |         |                |
// | url             | varchar(100)                   | YES  |     |         |                |
// | avatar          | varchar(200)                   | YES  |     |         |                |
// | gender          | enum('secret','male','female') | YES  |     | secret  |                |
// | birthday        | date                           | YES  |     | NULL    |                |
// | signature       | varchar(40)                    | YES  |     |         |                |
// | last_login_ip   | bigint(20) unsigned            | YES  |     | 0       |                |
// | last_login_time | int(11) unsigned               | YES  |     | 0       |                |
// | activation_key  | varchar(60)                    | YES  |     |         |                |
// | status          | tinyint(1)                     | YES  |     | 1       |                |
// | mobile          | varchar(20)                    | YES  |     |         |                |
// | member_id       | int(11) unsigned               | YES  |     | 0       |                |
// | create_time     | int(11) unsigned               | YES  |     | 0       |                |
// | update_time     | int(11) unsigned               | YES  |     | 0       |                |
// | delete_time     | int(11) unsigned               | YES  |     | 0       |                |
// +-----------------+--------------------------------+------+-----+---------+----------------+
namespace app\admin\validate;

use think\Validate;

class Member extends Validate
{
    protected $rule = [
        "id" => "gt:0",
        "name" => "min:2|max:30|unique:member",
        "nickname" => "min:2|max:30",
        "email" => "email|max:50|unique:member",
        "mobile" => "max:20|unique:member",
        "password" => "confirm:confirm_password|length:6,20",
        "url" => "url",
    ];

    protected $field = [
        "id" => "管理员ID",
        "name"  => "登录名",
        "nickname"  => "真实姓名",
        "email"  => "注册邮箱",
        "mobile"  => "手机号码",
        "password"  => "登录密码",
        "url" => "url",
    ];

    protected $message = [
        "id.gt" => "管理员ID不能为空",
        "name.min" => "登录名长度必须在2-30个字符之间",
        "name.max" => "登录名长度必须在2-30个字符之间",
        "name.name" => "当前登录名已注册",
        "nickname.min" => "用户昵称长度必须在2-30个字符之间",
        "nickname.max" => "用户昵称长度必须在2-30个字符之间",
        "email.email" => "注册邮箱格式不正确",
        "email.max" => "注册邮箱长度不能超过50个字符",
        "email.unique" => "当前邮箱已注册",
        "mobile.gt" => "手机号码格式不正确",
        "mobile.lt" => "手机号码格式不正确",
        "mobile.unique" => "当前手机号码已注册",
        "password.confirm" => "两次输入的密码不一致",
        "password.length" => "登录密码长度必须在6-20之间",
        "url" => "url格式不正确",
    ];

    protected $scene = [
        'create' => ['name', 'password'],
        'update' => ['id', 'name'],
    ];
}
